/**
 * 
 */
package pl.net.beercrm.util;

import java.util.Date;
import java.util.GregorianCalendar;

import javax.xml.datatype.DatatypeConfigurationException;
import javax.xml.datatype.DatatypeFactory;
import javax.xml.datatype.XMLGregorianCalendar;

/**
 * @author Rafi
 *
 */
public class DateUtil {

	public static XMLGregorianCalendar dateToXml(Date date) throws DatatypeConfigurationException {
		GregorianCalendar calendar = new GregorianCalendar();
		calendar.setTime(date);
		return DatatypeFactory.newInstance().newXMLGregorianCalendar(calendar);
	}
	
	public static Date xmlToDate(XMLGregorianCalendar calendar) {
		return calendar.toGregorianCalendar().getTime();
	}
}
